﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using System.Diagnostics;
using System.Runtime.InteropServices;
using Microsoft.Win32;
using SkinSharp;

namespace SN.Report
{
    static class Program
    {
        /// <summary>
        /// 应用程序的主入口点。
        /// </summary>
        [STAThread]
        static void Main()
        {
            //SkinH_Net skinn = new SkinH_Net();
            //skinn.AttachEx("skin\\xmp.she", "");
            //skinn.SetAero(0);

            AutoRegister(); //自动注册
            //Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new MainForm());
        }

        /// <summary>
        /// 自动注册ocx方法
        /// </summary>
        static void AutoRegister()
        {
            //GsFileName = Application.StartupPath; //获取当前应用程序所在目录的路径，最后不包含“\”；
            //GsFileName = AppDomain.CurrentDomain.BaseDirectory; //包含"\"
            Process p = new Process();
            p.StartInfo.FileName = "Regsvr32.exe";
            //注册第一个控件01E85C96-0576-423C-AA35-4DE078412088
            RegistryKey rkTest = Registry.ClassesRoot.OpenSubKey("CLSID\\{01E85C96-0576-423C-AA35-4DE078412088}\\");
            if (rkTest == null)
            {
                p.StartInfo.Arguments = "/s " + Application.StartupPath + "\\CellCtrl5.ocx";
                p.Start();
            }
            //注册第二个控件
            rkTest = Registry.ClassesRoot.OpenSubKey("CLSID\\{D8444751-A67E-424B-A006-FD8081B5C7BF}\\");
            if (rkTest == null)
            {
                //注册第三个控件
                p.StartInfo.Arguments = "/s " + Application.StartupPath + "\\RWXls.ocx";
                p.Start();
            }

        }

    }
}
